﻿Imports System

Imports Microsoft.VisualStudio.TestTools.UnitTesting

Imports LinqToNIEM

Imports System.Xml.Linq

'''<summary>
'''This is a test class for IServiceCallTest and is intended
'''to contain all IServiceCallTest Unit Tests
'''</summary>
<TestClass()> _
Public Class IServiceCallTest


    Private testContextInstance As TestContext

    '''<summary>
    '''Gets or sets the test context which provides
    '''information about and functionality for the current test run.
    '''</summary>
    Public Property TestContext() As TestContext
        Get
            Return testContextInstance
        End Get
        Set(ByVal value As TestContext)
            testContextInstance = Value
        End Set
    End Property

#Region "Additional test attributes"
    '
    'You can use the following additional attributes as you write your tests:
    '
    'Use ClassInitialize to run code before running the first test in the class
    '<ClassInitialize()>  _
    'Public Shared Sub MyClassInitialize(ByVal testContext As TestContext)
    'End Sub
    '
    'Use ClassCleanup to run code after all tests in a class have run
    '<ClassCleanup()>  _
    'Public Shared Sub MyClassCleanup()
    'End Sub
    '
    'Use TestInitialize to run code before running each test
    '<TestInitialize()>  _
    'Public Sub MyTestInitialize()
    'End Sub
    '
    'Use TestCleanup to run code after each test has run
    '<TestCleanup()>  _
    'Public Sub MyTestCleanup()
    'End Sub
    '
#End Region


    '''<summary>
    '''A test for RespondingOfficer
    '''</summary>
    <TestMethod()> _
    Public Sub SHOULD_PARSE_RESPONDING_OFFICER()
        Dim target As IServiceCall = CreateIServiceCall()
        Dim expected As New Officer With {.Dsn = "372", .LastName = "Peoples"}
        Dim actual As Officer = target.RespondingOfficer
        Assert.AreEqual(expected.Dsn, actual.Dsn)
        Assert.AreEqual(expected.LastName, actual.LastName)
    End Sub

    '''<summary>
    '''A test for ReportNumber
    '''</summary>
    <TestMethod()> _
    Public Sub SHOULD_PARSE_REPORT_NUMBER()
        Dim target As IServiceCall = CreateIServiceCall()
        Dim actual As String = target.ReportNumber
        Assert.AreEqual("509825-06", actual)
    End Sub

    '''<summary>
    '''A test for CallDescription
    '''</summary>
    <TestMethod()> _
    Public Sub SHOULD_PARSE_CALL_DESCRIPTION()
        Dim target As IServiceCall = CreateIServiceCall()
        Dim expected As String = "Caller believes father is missing.  Has not seen or heard from for 3 days.  States this is very unusual."
        Assert.AreEqual(expected, target.CallDescription)
    End Sub

    '''<summary>
    '''A test for CallDate
    '''</summary>
    <TestMethod()> _
    Public Sub SHOULD_PARSE_CALL_DATE()
        Dim target As IServiceCall = CreateIServiceCall()
        Dim expected As DateTime = CDate("2006-12-01T14:31:00.0Z")
        Dim actual As DateTime = target.CallDate
        Assert.AreEqual(expected, actual)
    End Sub

    <TestMethod()> _
    Public Sub SHOULD_BUILD_CONFORMANT_DOCUMENT()
        Dim target As LexsServiceCall = CreateIServiceCall()
        Dim doc As XDocument = target.BuildServiceCallDocument
        Diagnostics.Debug.WriteLine(doc)
        Assert.IsTrue(doc.ToString.Length > 0)
    End Sub

    Private Shared Function CreateIServiceCall() As LexsServiceCall
        Dim target As IServiceCall = New LexsServiceCall(XDocument.Load(String.Format("{0}\service-call-lexs.xml", GetDocumentPath())))
        Return target
    End Function

    'TODO To make tests work you'll have to change this path until I make it dynamic -CD
    Private Shared Function GetDocumentPath() As String
        Return "C:\Users\Chris\Documents\Projects\LinqToNIEM\LinqToNIEM\N-DEx-IncidentArrest-2.0.0\xml"
    End Function
End Class
